package pers.byxiaobai.levelhealth.message;

import org.bukkit.entity.Player;

import pers.byxiaobai.levelhealth.config.ConfigManager;

public class MessageManager {
	public static final MessageManager INSTANCE=new MessageManager();
	
	/**
	 * 当前血量
	 */
	private String healthVariable="%NOW_HEALTH%";

	/**
	 * 当前等级
	 */
	private String levelVariable="%NOW_LEVEL%";
	
	private String message;
	
	public void init() {
		message=ConfigManager.INSTANCE.getConfigYaml("config.yml").getString("LevelUpMessage.Message");
	}
	
	@SuppressWarnings("deprecation")
	public void sendLevelUpMessage(Player player) {
		String newMessage=message.replaceAll("&", "§");
		newMessage=newMessage.replaceAll(healthVariable, Double.toString(player.getMaxHealth()));
		newMessage=newMessage.replaceAll(levelVariable, Integer.toString(player.getLevel()));
		player.sendMessage(newMessage);
	}


	public String getHealthVariable() {
		return healthVariable;
	}


	public void setHealthVariable(String healthVariable) {
		this.healthVariable = healthVariable;
	}


	public String getLevelVariable() {
		return levelVariable;
	}


	public void setLevelVariable(String levelVariable) {
		this.levelVariable = levelVariable;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

}
